package TCP;

import java.io.IOException;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;

public class DictServer extends EchoServer{

    private Map<String,String> map = new HashMap<>();

    public DictServer(int port) throws IOException {
        super(port);

        map.put("cat", "小猫");
        map.put("dog", "小狗");
        map.put("pig", "小猪");
        map.put("bird", "小鸟");
        map.put("sheep", "小羊");
        map.put("cow", "小牛");
        map.put("chicken", "小鸡");
        map.put("rabbit", "小兔子");
        map.put("fish", "小鱼");
        map.put("wolf", "狼");
        map.put("monkey", "猴子");
        map.put("chicken", "小鸡");
        map.put("fish", "小鱼");
        map.put("tiger", "老虎");
        map.put("lion", "狮子");
        map.put("wolf", "狼");
        map.put("monkey", "猴子");
        //......
    }

    public String process(String request) {
        return map.getOrDefault(request,"没有查到该单词！");
    }

    public static void main(String[] args) throws IOException {
        EchoServer echoServer = new DictServer(9090);
        echoServer.start();
    }
}
